﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq;
using LMS.SMSH.BLL;
using LMS.SMSH.MODEL;



namespace LMS.SMSH.WEB
{
    public partial class AdmDevicePreserve : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }

        /// <summary>
        /// 将信息写入 “设备信息”TB_DeviceInfo表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            Int32? result = -1;
            LMSDataContext.GetLMSDB.sp_addDev(txtdevId.Text.Trim(), txtdevName.Text.Trim(), txtVender.Text.Trim(),
                                                DateTime.Parse(txtBuysDate.Text.Trim()), Decimal.Parse(txtCost.Text.Trim()),
                                                txtStatus.Text.Trim(), txtAtachmentNumber.Text.Trim(), ref result);
            switch (result)
            {
                case 1:
                    string strMsg = string.Format("alert('添加设备信息成功!');window.location.href='AdmDeviceList.aspx'");
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", strMsg, true);
                    break;
                case 0:
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('该设备的信息已经存在!')", true);
                    break;
                default:
                    break;
            }

        }

        /// <summary>
        /// 将数据值传入实体对象
        /// </summary>
        /// <returns></returns>
        //private TB_DeviceInfo GetTB_DeciceInfo()
        //{
        //    TB_DeviceInfo deviceInfo = new TB_DeviceInfo();
        //    deviceInfo.devAtachment = txtAtachmentNumber.Text.Trim();
        //    deviceInfo.devBoughtTime = DateTime.Parse(txtBuysDate.Text.Trim());
        //    deviceInfo.devCost = Decimal.Parse(txtCost.Text.Trim());
        //    deviceInfo.devId = txtdevId.Text.Trim();
        //    deviceInfo.devName = txtdevName.Text.Trim();
        //    deviceInfo.devStatus = txtStatus.Text.Trim();
        //    deviceInfo.devVender = txtVender.Text.Trim();
        //    return deviceInfo;
        //}


    }
}